package org.ruanjj.collection;

import java.util.*;

public class CitiMapTest{
    public static void main(String[] args) {
        Map model = CitiMap.model;
        Set citySet = model.keySet();
        Iterator iterator = citySet.iterator();
        while(iterator.hasNext()){
            System.out.print(iterator.next()+"\t\t");
        }
        Scanner scanner = new Scanner(System.in);
        String province = "";
        while(true){
            System.out.print("\n请输入你所在的省份：");
            province = scanner.next();
            if(!model.containsKey(province)){
                System.out.println("您输入的不正确,请重新输入！");
            }else{
                break;
            }
        }

        String[] values = (String[]) model.get(province);

        for(String value:values){
            System.out.print(value+"\t\t");
        }

        while(true){
            System.out.print("\n请输入你所在的城市：");
            String city = scanner.next();
            if(!(Arrays.asList(values)).contains(city)){
                System.out.println("您输入的不正确，请重新输入！");
            }else{
                break;
            }
        }

        System.out.println("信息登记完毕");

    }

}
